import { _decorator, Component, Layout, Node, UITransform } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Menu_Btn_Flex')
export class Menu_Btn_Flex extends Component {
    resetNodes() {
        let children = this.node.children
        if(children.length == 0) return

        let child = children[0]
        let childW = child.getComponent(UITransform).width
        let count = children.length;
        let width = this.node.getComponent(UITransform).width;
        let remain = width-childW*count
        // let  spaceX = remain/(count*2+2)
        // this.node.getComponent(Layout).spacingX = spaceX
        // this.node.getComponent(Layout).paddingLeft = spaceX*2
        // this.node.getComponent(Layout).paddingRight = spaceX*2
        let  spaceX = remain/(count+1)
        this.node.getComponent(Layout).spacingX = spaceX
        this.node.getComponent(Layout).paddingLeft = spaceX
        this.node.getComponent(Layout).paddingRight = spaceX
    }
}


